package com.ruoyi.servie.config;

import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.github.binarywang.wxpay.config.WxPayConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WechatConfiguration {

    @Value("${wechat.appId}")
    private String appId;

    @Value("${wechat.secret}")
    private String secret;

    @Value("${wechat.mchId}")
    private String mchId;

    @Value("${wechat.key}")
    private String key;

    @Bean
    public WxMaDefaultConfigImpl WeChatClient(){
        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(appId);
        wxMaDefaultConfig.setSecret(secret);
        return wxMaDefaultConfig;
    }

    @Bean
    public WxPayConfig WeChatAppletPayClient(){
        WxPayConfig wxPayConfig = new WxPayConfig();
        wxPayConfig.setAppId(appId);
        wxPayConfig.setMchId(mchId);
        wxPayConfig.setMchKey(key);
        return wxPayConfig;
    }

}
